<template>
  <div style='display:flex;'>
    <!-- {{value1}}
    <el-upload
      class="pic-uploader-component"
      :action="$http.adornUrl(url)"
      :headers="{Authorization: $cookie.get('Authorization')}"
      :show-file-list="false"
      :on-success="handleUploadSuccess"
      :before-upload="beforeAvatarUpload">
      <img v-if="value" :src="resourcesUrl + value" class="pic">
      <img v-else src="https://up.enterdesk.com/edpic_360_360/df/4f/61/df4f611600c63e7707e38925f36671ea.jpg">
    </el-upload>
    {{value2}} -->
    <!-- <el-upload
      class="pic-uploader-component"
      :action="$http.adornUrl(url)"
      :headers="{Authorization: $cookie.get('Authorization')}"
      :show-file-list="false"
      :on-success="handleUploadSuccess"
      :before-upload="beforeAvatarUpload">
      <img v-if="value" :src="resourcesUrl + value" class="pic">
      <img v-else src="https://up.enterdesk.com/edpic_360_360/df/4f/61/df4f611600c63e7707e38925f36671ea.jpg">
    </el-upload> -->
  </div>
</template>

<script>
  export default {
    data () {
      return {
        resourcesUrl: window.SITE_CONFIG.resourcesUrl
      }
    },
    props: {
      value: {
        default: '',
        type: String
      },
      url: {
        default: '/admin/file/upload/element',
        type: String
      }
    },
    methods: {
      // 图片上传
      handleUploadSuccess (response, file, fileList) {
        this.$emit('input', file.response)
      },
      // 限制图片上传大小
      beforeAvatarUpload (file) {
        const isLt2M = file.size / 1024 / 1024 < 5
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 5MB!')
        }
        return isLt2M
      }
    }
  }
</script>

<style lang="scss">
// .avue-upload__avatar, .avue-upload__icon, .el-upload--picture-card, .el-upload-list--picture-card .el-upload-list__item {
//     width: 300px;
//     height: auto;
//     line-height: auto;
// }

// .el-upload-list--picture-card .el-upload-list__item {
//     overflow: hidden;
//     background-color: #fff;
//     border: 1px solid #c0ccda;
//     border-radius: 6px;
//     -webkit-box-sizing: border-box;
//     box-sizing: border-box;
//     width: auto;
//     margin: 0 8px 0 0;
//     display: inline-block;
// }
// .el-upload.el-upload--picture-card {
//     width: 180px;
//     height: 180px;
//     line-height: 180px;
// }
.pic-uploader-component .el-upload {
 margin-right: 18px;
}
</style>